package com.zhongge.comparerelevant.comparator;

/**
 * @ClassName Test
 * @Description TODO
 * @Author zhongge
 * @Version 1.0
 */
public class Test {
    public static void main(String[] args) {
        //创建学对象
        Student student1 = new Student("wanwu", 60);
        Student student2 = new Student("lisi", 90);

        //根据年龄进行比较
        System.out.println("根据年龄进行比较");
        //1.实例化年龄比较器对象
        AgeComparator ageComparator = new AgeComparator();
        //2.判断逻辑
        if (ageComparator.compare(student1, student2) >0 ) {
            System.out.println("student1 > student2");
        } else {
            System.out.println("student1 <= student2");
        }

        System.out.println("===================");

        //根据姓名进行比较
        System.out.println("根据姓名进行比较");
        //1.实例化姓名比较器对象
        NameComparator nameComparator = new NameComparator();
        //2.判断逻辑
        if (nameComparator.compare(student1, student2) >0 ) {
            System.out.println("student1 > student2");
        } else {
            System.out.println("student1 <= student2");
        }
    }
}
